﻿using System;
using System.ServiceModel;
using ExplorerService.Common.ServiceContracts;
using ExplorerService.Managers;

namespace ExplorerService.Communication
{
    public class ClientStreamingService: ClientSessionMonitoredService, IClientStreamingService
    {
        /// <summary>
        /// Method called to clean up service resources
        /// </summary>
        protected override void ServiceDispose()
        {
            
        }

        /// <summary>
        /// Registers a new uploadStream
        /// </summary>
        /// <returns>The new ID of the stream</returns>
        public Guid BeginUploadStream(Guid clientSessionId)
        {
            VerifySessionIdAndRegister(clientSessionId);
            return StreamManager.Instance.BeginUploadStream(clientSessionId, OperationContext.Current.GetCallbackChannel<IClientStreamingServiceCallback>());
        }

        /// <summary>
        /// Registers a new downloadStream
        /// </summary>
        /// <returns>The new ID of the stream</returns>
        public Guid BeginDownloadStream(Guid clientSessionId)
        {
            VerifySessionIdAndRegister(clientSessionId);
            return StreamManager.Instance.BeginDownloadStream(clientSessionId,
                                                              OperationContext.Current.GetCallbackChannel
                                                                  <IClientStreamingServiceCallback>());
        }

        /// <summary>
        /// Ends the upload stream
        /// </summary>
        public void EndStream()
        {
            
        }
    }
}
